import { IPSPanelItem } from './ipspanel-item';
import { IPSSysPanelContainer } from './ipssys-panel-container';
import { PSSysPanelContainerImplBase } from './pssys-panel-container-impl-base';

export class PSSysPanelContainerImpl extends PSSysPanelContainerImplBase implements IPSSysPanelContainer {
  get captionItemName(): string {
    return this.M.captionItemName;
  }

  protected pspanelitems: IPSPanelItem[] | null = null;

  getPSPanelItems(): IPSPanelItem[] | null {
    if (this.pspanelitems == null) {
      this.pspanelitems = this.fillChildListModel(this.M.getPSPanelItems, 'control.panel.IPSPanelItem') as IPSPanelItem[];
    }
    return this.pspanelitems;
  }

  get psPanelItems(): IPSPanelItem[] | null {
    return this.getPSPanelItems();
  }

  findPSPanelItem(objKey: any): IPSPanelItem | null {
    return this.getPSModel5('control.panel.IPSPanelItem', this.getPSPanelItems(), objKey) as IPSPanelItem;
  }

  get predefinedType(): string {
    return this.M.predefinedType;
  }

  get titleBarCloseMode(): 0 | 1 | 2 {
    return this.M.titleBarCloseMode != null ? this.M.titleBarCloseMode : 0;
  }

  get cls(): string {
    return 'PSSysPanelContainerImpl';
  }

  instanceof(cls: string): boolean {
    if (
      cls == 'IPSModelObject' ||
      cls == 'IPSObject' ||
      cls == 'control.IPSControlItem' ||
      cls == 'control.layout.IPSLayoutItem' ||
      cls == 'control.panel.IPSPanelContainer' ||
      cls == 'control.panel.IPSPanelItem' ||
      cls == 'control.panel.IPSPanelObject' ||
      cls == 'control.panel.IPSSysPanelContainer' ||
      cls == 'control.panel.IPSSysPanelItem'
    )
      return true;
    return super.instanceof(cls);
  }
}
